<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ 
	taglib prefix="s" uri="/struts-tags"%><%@ 
	include file="/taglibs.jsp"%>

<c-rt:set var="now" value="<%=new java.util.Date(System.currentTimeMillis())%>"/>
<s:url value="/js" var="jsPath"/>
<s:url value="/css" var="cssPath"/>
<s:url value="/images" var="imgPath"/>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="${jsPath}/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="${jsPath}/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="${cssPath}/smoothness.datepick.css" />
<!-- 時間 -->	
<script type="text/javascript" charset="UTF-8" src="${jsPath}/jquery-ui-1.7.2.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="${cssPath}/jquery-ui-1.7.2.custom.css"/>

<script language="javascript">
function customRange (){
	var startDt = $('#paramStartDateTime').val(); //起始日
	var endDt = new Date(parseInt(startDt.substring(0,4),10),parseInt(startDt.substring(5,7),10)-1,parseInt(startDt.substring(8,10),10)); //結束日
	return {minDate:endDt}; 
}

$().ready( function() {
	$('#paramStartDateTime').datepick({minDate: null, showOn: 'both', 
    	buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
	$('#paramEndDateTime').datepick({minDate: new Date(), showOn: 'both', 
	   	  buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,beforeShow:customRange,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
});	
</script>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br />
<h1>运费折抵活动管理
<div class="f-link">
<a href="add.do">新增</a>
<a href="#" onclick="document.formObj.submit();">搜寻</a>
</div>
</h1>
<div class="data-form">
<s:form action="search.do" method="post" name="formObj">
<table width="850">
<tr>
	<td width="15%">活动名称：</td>
	<td width="35%"><s:textfield name="paramName"/></td>
	<td width="15%">最低订单金额：</td>
	<td width="35%"><s:textfield name="paramMinOrderAmount"/></td>
</tr>
<tr>
	<td width="15%">活动时间：</td>
	<td width="35%">
	<s:textfield name="paramStartDateTime" id="paramStartDateTime" size="10"/>
	~
	<s:textfield name="paramEndDateTime" id="paramEndDateTime" size="10"/>
	</td>
	<td width="15%">启用：</td>
	<td width="35%"><s:checkboxlist list="#{'true':'是','false':'否'}" listKey="key" listValue="value" name="paramEnable"/></td>
</tr>
</table>
</s:form>
</div>
<br/><br/>
	<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th>#</th>
				<th>行销活动名称</th>
				<th>适用对象</th>
				<th>活动开始时间</th>
				<th>活动结束时间</th>
				<th>最低订单金额</th>
				<th>折扣 kg</th>
				<th>启用</th>
			</tr>
		</thead>
		<s:if test="campaignList.size > 0">
		<tbody>
			<c:forEach items="${campaignList}" var="campaign" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td><a href="view.do?uuid=${campaign.uuid}" /><fmt:formatNumber
						pattern="0000" value="${rows_index.count + pager.currentPage*20}" /></a></td>
					<td>${campaign.campaignName}</td>
					<td>${menuMemberRank.options[campaign.allowMemberRank].name}</td>
<c:set var="fontColor" value="block"/>
<c:if test="${campaign.startDateTime ge now}"><c:set var="fontColor" value="green"/></c:if>
<c:if test="${campaign.endDateTime le now}"><c:set var="fontColor" value="green"/></c:if>
					<td style="color:${fontColor}">
<fmt:formatDate value="${campaign.startDateTime}" pattern="yyyy-MM-dd HH:mm" />
					</td>
					<td style="color:${fontColor}">
<fmt:formatDate value="${campaign.endDateTime}" pattern="yyyy-MM-dd HH:mm" />
					</td>
					<td>${campaign.minOrderAmount}</td>
					<td>${campaign.discountData}</td>
					<td><c:if test="${campaign.enable}">是</c:if><c:if test="${!campaign.enable}"><div style="color:green">否</div></c:if></td>
				</tr>
			</c:forEach>
		</tbody>
		</s:if>
		<s:else>
			<tbody>
				<tr class="bg-yl"><td colspan="6">查无资料!!</td></tr>
			</tbody>
		</s:else>
	</table>	
	<yaodian100:pageutil link="search.do" pagerObj="${pager}" />
